<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <title>阻止事件的冒泡</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }

        .box1 {
            width: 200px;
            height: 200px;
            background-color: red;
            display: flex;
            justify-content: center;
            align-items: center;
        }

        .box2 {
            width: 100px;
            height: 100px;
            background-color: green;
        }
    </style>
</head>
<body>
<div id="app">
    <div class="box1" v-on:click="box1clicked">
        <!--.stop 修饰符 用来阻止事件的冒泡-->
        <div class="box2" v-on:click.stop="box2clicked"></div>
    </div>
</div>

<script type="module">
    import {createApp} from "../../../js/vue.esm-browser.js";

    let app = createApp(
        {
            setup() {
                function box1clicked() {
                    console.log("点击了 外部区域");
                }

                function box2clicked() {
                    console.log("点击了 内部区域");
                }

                return {
                    box1clicked, box2clicked,
                }
            }
        }
    );

    app.mount("#app")
</script>
</body>
</html>